<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<div class="content">
	<div class="notice">
		&lt;&lt;文章&gt;&gt;管理<br />&nbsp;&nbsp;
		<a href="PostServlet?action=newPost">写文章</a>
	</div>
	<div class="notice">
		&lt;&lt;文章分类&gt;&gt;管理<br />
		<form action="PostServlet">
			<input type="text" name="category"/>
			<input type="hidden" name="action" value="addCate"/>
			<input type="submit" value="添加分类"/>
		</form>
		
		<table>
			<tr>
				<td style="width: 30px">Id</td>
				<td style="width: 100px">分类名称</td>
				<td style="width: 40px" colspan="2">操作</td>
			</tr>
			<c:forEach items="${categoryList}" var="category">
			<form action="PostServlet" method="post">
			<input type="hidden" name="id" value="${category.id }"/>
			<tr>
				<td>${category.id }</td>
				<td><input type="text" name="name" value="${category.name }"/></td>
				<td><input type="submit" value="编辑"/></td>
				<td><a href="PostServlet?action=deleteCate&id=${category.id }">删除</a></td>
			</tr>
			<input type="hidden" name="action" value="editCate"/>
			</form>
			</c:forEach>
		</table>
	</div>
	<div class="notice">
		&lt;&lt;用户&gt;&gt;管理<br />
		${error }<br />
		<form action="PostServlet" method="post">
			用户名：<input type="text" name="username"/><br />
			密&nbsp;&nbsp;&nbsp;码：<input type="password" name="password" />&nbsp;&nbsp;重复密码：<input type="password" name="repassword"/><br />
			昵&nbsp;&nbsp;&nbsp;称：<input type="text" name="nickname"/><br />
			Email：&nbsp;<input type="text" name="email"/><br />
			角&nbsp;&nbsp;色：<select name="status">
				<option value="1">管理员</option>
				<option value="2">作者</option>
				<option value="3">读者</option>
			</select>
			<br />
			<input type="hidden" name="action" value="addUser"/>
			<input type="submit" value="添加用户"/>
		</form>
		<hr />
		<table>
			<tr>
				<td style="width: 40px">用户名</td>
				<td style="width: 40px">昵称</td>
				<td style="width: 150px">Email</td>
				<td style="width: 150px">注册时间</td>
				<td style="width: 60px">角色</td>
				<td style="width: 80px" colspan="2">操作</td>
			</tr>
			<c:forEach items="${userList}" var="user">
			<form action="PostServlet" method="post">
			<input type="hidden" name="id" value="${user.id }"/>
			<tr>
				<td><input type="text" name="username" style="width: 40px" value="${user.username}"/></td>
				<td><input type="text" name="nickname" style="width: 40px" value="${user.nickname}"/></td>
				<td><input type="text" name="email"  style="width: 150px" value="${user.email}"/></td>
				<td  style="width: 150px">${user.registered}</td>
				<td>
				<select name="status">
					<option 
						<c:if test="${user.status == 1}"> selected=selected</c:if> 
						value="1">管理员</option>
					<option 
						<c:if test="${user.status == 2}"> selected=selected</c:if> 
						value="2">作者</option>
					<option 
						<c:if test="${user.status == 3}"> selected=selected</c:if> 
						value="3">读者</option>
				</select>
				</td>
				<td><input type="submit" value="编辑"/></td>
				<td><a href="PostServlet?action=deleteUser&id=${user.id }">删除</a></td>
			</tr>
			<input type="hidden" name="action" value="editUser"/>
			</form>
			</c:forEach>
		</table>
	</div>
</div>